<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.List,nc.vo.ebpur.qualifitype.QualifiTypeVO"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path =request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>

		<title>下拉列表</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link href="<%=path%>/css/main.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/dialog.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css" />
		<script src="<%=path %>/js/jquery-1.4.4.js" type="text/javascript"></script>
		
		<script type="text/javascript">
			function choose1() {
				var objs = document.getElementsByName("check1");
				if(objs.length>0){
					var codes=document.getElementsByName("code1");
					var names=document.getElementsByName("name1");
					var pkmarClss=document.getElementsByName("pkqaCl1");
					for(var i=0;i<objs.length; i=i+1){	
						if(objs[i].checked){
							var code=codes[i].value;
							var name=names[i].value;
							var pkmarCls=pkmarClss[i].value;
							//如果不存在产品分类，则添加
							if(!isExistCl(pkmarCls)){
								addProdClInfo(code,name,pkmarCls);
							}else{
								alert("编码为'"+code+"'的资质分类已添加");
								return ;
							}
						}
					}
				}
				parent.hideMe();
			}

			//检查是否已存在选择的分类
			function isExistCl(pkmarCl){
				var flag=false;
				if(pkmarCl!=null){
					var pkQaCLs=parent.document.getElementsByName("pkQaCl");
					if(pkQaCLs!=null && pkQaCLs.length>0){
						for(var i=0;i<pkQaCLs.length;i++){
							if(pkmarCl==pkQaCLs[i].value){
								flag=true;
								break;
							}
						}	
					}
				}
				return flag;
			}
			
			function clearvalue(){
				parent.hideMe();
			}
			
			function addProdClInfo(code,name,pkmarCl) {
				var qaList = parent.document.all("qaList");
				if(qaList != null) {
			 		var row = qaList.insertRow();
			 		var rows = qaList.rows;
					row.id=pkmarCl;
					//序号
					var cell = row.insertCell();
					cell.align = 'center';
					cell.innerHTML = rows.length-1;
					//名称	
			 		cell = row.insertCell();
			 		cell.align = 'center';
			 		cell.innerHTML = "<input type='text' id='"+pkmarCl+"-name' class='list_text_2' name='name' value='"+name+"' readOnly/>";
			 		//删除
			 		cell = row.insertCell();
			 		cell.align = 'center';
			 		cell.innerHTML = "<a href=\"javascript:deleteRowById('"+pkmarCl+"')\" class=\"linkstyle3\">删除</a> <input type='hidden' name='pkQaCl' value='"+pkmarCl+"' />";
			 	}
			}
			 
		</script>
	</head>

	<body>
		<div style="ovoverflow-y:scroll;width:100%;height:100%">
			<p>资质分类信息</p>
			<form name="form1">
				<table  border="0" cellspacing="0" class="subpage_table1 withborder2">
					<tr>
						<th width="50"  align="center">选择</th>
						<th width="100"  align="center">编码</th>
						<th width="100" align="center">名称</th>
					</tr>
					<c:if test="${qaList!=null}">
						<c:forEach items="${qaList}" var="qaCls" varStatus="index">
							<tr align="center">
							<td>
								<input name="pkqaCl1" type="hidden" value="${qaCls.pk_qualifitype}"/>
								<input name="check1" type="checkbox" />
							</td>
							<td><input name="code1" type="text" class="list_text_1"  value="${qaCls.qualifitype_code}" /></td>
							<td><input name="name1" type="text" class="list_text_2"  value="${qaCls.qualifitype_name}" /></td>
						</c:forEach>
					</c:if>
				</table>
			</form>
			<p></p>
			<div align="center">
				<input type="button" class="buttonok" value="确定" onclick="javascript: choose1();"/>
					&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="buttoncan" value="关闭" onclick="clearvalue()"/>
			</div>
		</div>
	</body>
</html>
